﻿<%--
 *  File:    VisitPlanFeedbackDetail4Doc.jsp
 *  @Author: Tao Wei 
 *  Date:    2010-11-18
 *
 *  Copyright (C) 2000 - 2010 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>


<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>


<%

  String strTableName = "";
  String strModuleName = "SFE";
  String privilegeCode = "ALL";
  String contextPath = request.getContextPath();
  java.util.HashMap userInfo = (java.util.HashMap)session.getAttribute("userinfo"); 
  Integer nCurUserId = (Integer)userInfo.get("userid");
  Integer contactid = null;
  if (request.getParameter("contactid") != null&&request.getParameter("contactid")!=""){
	 contactid = Integer.valueOf(request.getParameter("contactid"));
  }else {
	 contactid = (Integer)userInfo.get("userid");
  }
%>

<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>
<%@ include file="/inc/InitConstant.inc" %>
<html>
<head>
<title>VisitPlanFeedbackDetail4Doc</title>
 <%@ include file="/sfe/VisitPlanMaincss.inc"%>
<% if("Y".equals(request.getParameter("isconfirm"))){ %>
<script>
	window.opener.page_summary('search');
	window.close();
</script>
<% return;} %>
<PageFlow:CheckPageFlow pageName="p_visitfeedbackdetail4doc"/>
<%

int nYear=((Integer)pageContext.getAttribute("year")).intValue();
int nMonth=((Integer)pageContext.getAttribute("monthofyear")).intValue();
int nWeek=((Integer)pageContext.getAttribute("weekofmonth")).intValue();
int nDay=((Integer)pageContext.getAttribute("dayofweek")).intValue();
Date dWeekStart=null;
Date planToday=null;
Calendar cal=Calendar.getInstance();
cal.clear();
cal.set(Calendar.YEAR,nYear);
cal.set(Calendar.MONTH,nMonth-1);
cal.set(Calendar.WEEK_OF_MONTH,nWeek);
//cal.set(Calendar.DAY_OF_WEEK,nDay);
cal.setFirstDayOfWeek(Calendar.MONDAY);
dWeekStart=cal.getTime();
cal.set(Calendar.DAY_OF_WEEK, nDay);
cal.add(Calendar.DATE, 1); 
planToday=cal.getTime();
//out.print(new java.sql.Date(planToday.getTime()));
if(nDay==1){
	planToday=dWeekStart;	
}

String[] weekLabelArrs=new String[]{"L_Monday","L_Tuesday","L_Wednesday","L_Thursday","L_Friday","L_Saturday","L_Sunday"};
String strFullDateFormat=label.getLabelName("L_FullDateFormat");
String strWeekShow=label.getLabelName(weekLabelArrs[nDay-1]);		
java.text.SimpleDateFormat sdf=new java.text.SimpleDateFormat(strFullDateFormat);

String flag = (String)pageContext.getAttribute("flag");
if(flag == null) flag = new String("");
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="javascript" type="text/javascript" src="<%=contextPath %>/js/datePicker/WdatePicker.js"></script>
<%@ include file ="/inc/NewCalendar.inc" %>
<script language="JavaScript">
	function page_close()
	{
		window.close();
	}
	function page_setfileid(num,id)
	{
		var myform = eval("document.cform");
		var fileobj=eval("myform.feedbackattrachid"+num);
			
		if(!isEmpty(id))
		{
			fileobj.value=id;
		}
		else
		{
			fileobj.value=" ";
		}
	}
function page_confirmback(num)
{	
	var t = null;
  if(top.topFrame != null)
    t = top.topFrame;
  if(t == null && opener != null && opener.top != null && opener.top.topFrame != null)
    t = opener.top.topFrame;
  if(t == null && opener != null && opener.opener != null && opener.opener.top != null && opener.opener.top.topFrame != null)
    t = opener.opener.top.topFrame;
  if(t != null)
    message = t.message;
  else
    message = new ActiveXObject("Scripting.Dictionary");
	var myform = eval("document.cform");
		myform.starttime.value=myform.planvisitdate.value+" "	+"1:00:00";
		myform.endtime.value=myform.planvisitdate.value+" "	+"23:59:00";
		for(i=0;i<Number(myform.numrows.value);i++)
		{

			if(i<=num){
						var objnumber=eval("myform.feedbacknumber"+i);
						var attrname=eval("myform.attrname"+i);
						if(objnumber!=null && isEmpty(objnumber.value))
						{
							alert(replaceString("<%= message.getMessageDesc("VALUE_NOT_NULL")%>","%s",attrname.value.replace("\'","'")));
							return;
						}
						if(objnumber!=null && !isNumeric(objnumber.value))
						{
							alert(replaceString("<%= message.getMessageDesc("VALUE_NOT_NULL")%>","%s",attrname.value.replace("\'","'")));
							return;
						}
						var objtext=eval("myform.feedbacktext"+i);
			//if(objtext!=null && isEmpty(objtext.value))
			//{
			//	alert(replaceString(message.Item("VALUE_NOT_NULL"),"%s",attrname.value.replace("\'","'")));
			//	return;
			//}
						if(objtext!=null&& !isEmpty(objtext.value) ) 
						{
							if(objtext.value.length >200 ) {
							   alert(attrname.value+"<%=message.getMessageDesc("Input_Long")%>");
							  //alert(attrname.value);
							  // alert(replaceString(message.Item("Input_Long"),"%s",attrname.value.replace("\'","'")));
								return;
								}
						}
			
						var objselected=eval("myform.feedbackselect"+i);
						if(objselected!=null && isEmpty(objselected.value))
						{
							alert(replaceString("<%= message.getMessageDesc("VALUE_NOT_NULL")%>","%s",attrname.value.replace("\'","'")));
							return;
						}
						var objattrach=eval("myform.feedbackattrachid"+i);
						if(objattrach!=null && isEmpty(objattrach.value))
						{
							alert(replaceString("<%= message.getMessageDesc("VALUE_NOT_NULL")%>","%s",attrname.value.replace("\'","'")));
							return;
						}
		
			}
		
			var objscheck=eval("myform.sfeedbackcheck"+i);
			var objcheck=eval("myform.feedbackcheck"+i);
			if(objscheck!=null && objscheck.checked)
			{
				objcheck.value="Y";
			}
			else if(objscheck!=null && !objscheck.checked)
			{
				objcheck.value="N";
			}
		  var attrname=eval("myform.attrname"+i);
			var objtext=eval("myform.feedbacktext"+i);
			if(objtext!=null&& !isEmpty(objtext.value) ) 
			{
				if(objtext.value.length >200 ) {
				   alert(attrname.value+"<%=message.getMessageDesc("Input_Long")%>");
				  //alert(attrname.value);
				  // alert(replaceString(message.Item("Input_Long"),"%s",attrname.value.replace("\'","'")));
					return;
					}
			}
			
			var objnumber=eval("myform.feedbacknumber"+i);
			if(objnumber!=null && !isNumeric(objnumber.value))
			{
				alert(replaceString("<%= message.getMessageDesc("VALUE_NOT_NULL")%>","%s",attrname.value.replace("\'","'")));
				return;
			}
		}
		
		if(!checkType(myform.visitdate)) return;
	  if(!checkCommand(myform.visitdate)) return;
	
		myform.actionname.value = "save";
	 	myform.target="_self";
	 	isRunning = true;
	 	myform.submit();
}

</script>
</head>
<body>
	<form name="cform" method="post" action="<%=contextPath%>/Dispatcher">
    <input type="hidden" name="pagename" value="p_visitfeedbackdetail4doc">
    <input type="hidden" name="actionname">
    <custom:hidden property="customerid"/>
    <custom:hidden property="contactid"/>
    <custom:hidden property="year"/>
    <custom:hidden property="monthofyear"/>
    <custom:hidden property="weekofmonth"/>
    <custom:hidden property="dayofweek"/>
    <custom:hidden property="dayofmonth"/>
    <custom:hidden property="ishistory"/>	
    <custom:hidden property="processid"/>
     <%
    Calendar firstweeknowcal = Calendar.getInstance();
	firstweeknowcal.clear();
	firstweeknowcal.set(Calendar.YEAR, nYear);
	firstweeknowcal.set(Calendar.MONTH, nMonth-1);
	firstweeknowcal.set(Calendar.WEEK_OF_MONTH, nWeek);
	firstweeknowcal.setFirstDayOfWeek(Calendar.MONDAY);
	//out.print(new java.sql.Date(((Date)firstweeknowcal.getTime()).getTime()));	
   /*
    int mondayPlus;
    Calendar nowfirstcal = Calendar.getInstance();
    //	 获得今天是一周的第几天，星期日是第一天，星期二是第二天......
	int dayOfWeek = nowfirstcal.get(Calendar.DAY_OF_WEEK) - 1; // 因为按中国礼拜一作为第一天所以这里减1
	if (dayOfWeek == 1) {
	  mondayPlus = 0;
	} else {
	  mondayPlus = 1 - dayOfWeek;
	}
	GregorianCalendar currentDate = new GregorianCalendar();
	currentDate.add(GregorianCalendar.DATE, mondayPlus);
	Date monday = currentDate.getTime();
	*/
	Calendar nowfirstcal=Calendar.getInstance();
	nowfirstcal.setFirstDayOfWeek(Calendar.MONDAY);
	nowfirstcal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);	
    %>
	<custom:hidden name="visitplandetailinfo" property="planvisitdate"/>	
	<custom:hidden name="visitplandetailinfo" property="flag"/>
   <table width="100%" cellspacing="0" border="0" cellpadding="0">
     
      <tr>
        <td>
          
          <table width="100%" border="0" cellspacing="0">
           
            <tr><td class="summary_top"></td></tr>
            <tr><td ><%=label.getLabelName("L_BasicInfo")%><%=label.getLabelName("L_Colon")%></td></tr>
            
          </table>
        </td>
      </tr>
      <tr>
        <td>
          <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
             <tr > 
          			<td width="10%"><%=label.getLabelName("L_VisitActivityFeedback")%></td>
          			<td width="40%"><%=sdf.format(planToday)%>(<%=strWeekShow%>)</td>
          			<td width="10%"><%=label.getLabelName("L_Status")%></td>
          			<td width="40%"><custom:write  property="plandetailstatus"  name="visitplandetailinfo"  nbsp="true" dictType="Status"/></td>
          	</tr>
          	<tr> 
				<td width="10%"><%=label.getLabelName("L_DoctorName")%></td>
				<td width="40%">
					<custom:write name="doctorhash" property="doctorname" nbsp="true" />
					<custom:hidden name="doctorhash" property="doctorid" />
				</td>
				<td width="10%"><%=label.getLabelName("L_Hospital")%></td>
          		<td width="40%">
					<custom:write name="visitplandetailinfo" property="customercode" nbsp="true"/>
					&nbsp;
					<custom:write name="visitplandetailinfo" property="customername" nbsp="true"/>
				</td>
          	</tr>
          	<tr > 
          			<td width="10%"><%=label.getLabelName("L_VisitProcess")%></td>
          			<td width="40%"><custom:write  property="processnames" nbsp="true"/></td>
          			<td width="10%"><%=label.getLabelName("L_CreateDate")%></td>
          			<td width="40%"><custom:write name="visitplandetailinfo" property="createdate" dataType="date" dataFormatName="dateformat" nbsp="true"/></td>
          			
          	</tr>
          	<%
          	java.text.SimpleDateFormat sdf2Time=new java.text.SimpleDateFormat("HH:mm");
          	HashMap visitplandetailinfo=(HashMap)pageContext.getAttribute("visitplandetailinfo");
          	if(visitplandetailinfo==null)
          		visitplandetailinfo=new HashMap();
          	
          			Date dStart=(Date)visitplandetailinfo.get("planstarttime");
          			Date dEnd=(Date)visitplandetailinfo.get("planendtime");
          			String sStart="";
          			String sEdit="";
          			if(dStart!=null)
          				sStart=sdf2Time.format(dStart);
          			if(dEnd!=null)
          				sEdit=sdf2Time.format(dEnd);
          	%>
          	<!-- 
          	<tr > 
          			<td width="120"><%=label.getLabelName("L_VisitPlanStartTime")%></td>
          			<td  ><%=sStart%></td>
          			<td width="120"><%=label.getLabelName("L_VisitPlanEndTime")%></td>
          			<td ><%=sEdit%></td>
          			
          	</tr>
          	 -->
          	<tr > 
          			<td width="10%"><%=label.getLabelName("L_LastVisitDate")%></td>
          			<td width="40%"><custom:write name="lastvisitdate" property="lastvisitdate"  nbsp="true"/></td>
          			<td width="10%"><%=label.getLabelName("L_CountVisitOfMonth")%></td>
          			<td width="40%"><custom:write name="visitcount" property="count_doc"  nbsp="true"/></td>
          	</tr>
          	<tr > 
          		<!--  <td width="120"><%=label.getLabelName("L_DoctorGrade")%></td>
          		  <td  ><custom:write name="dochash" property="doclevel"  nbsp="true"/></td>-->
          		  <td><%=label.getLabelName("L_VisitDate")%></td>
          		  <td>
          		  <custom:text name="feedbackinfo" property="visitdate"  dataType="date"  label="L_VisitDate" dataFormat="yyyy-MM-dd" styleClass="Wdate"  command="notnull"  onclick="javacript:WdatePicker();" style="width:90px;"></custom:text>
          		  <a onclick="javascript:c.show(this,'cform.visitdate','yyyy-MM-dd');"><custom:button type="3" label="L_Asterisk" imgsrc="Time.gif" border="0"/></a>
          		  
                 <!--   <custom:text name="feedbackinfo" property="visitdate" dataType="date" dataFormatName="dateformat"  size="20" command="notnull" label="L_VisitDate"/>
                  <a onclick="show_calendar('cform.visitdate','<%= session.getAttribute("dateformat")%>');"><custom:button type="3" label="L_Asterisk" imgsrc="Time.gif" border="0"/></a>
               --></td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
          	</tr>
          	
          	<%
          	HashMap feedbackinfo=(HashMap)pageContext.getAttribute("feedbackinfo");
          	if(feedbackinfo==null)
          		feedbackinfo=new HashMap();
          	Integer oStatus=(Integer)feedbackinfo.get("status");
          	
          	if(oStatus!=null && oStatus.intValue()==99)
          		pageContext.setAttribute("displayflag","view");
          			Date dActualStart=(Date)feedbackinfo.get("starttime");
          			Date dActualEnd=(Date)feedbackinfo.get("endtime");
          			String sActualStart="";
          			String sActualEdit="";
          			if(dActualStart!=null)
          				sActualStart=sdf2Time.format(dActualStart);
          			if(dActualEnd!=null)
          				sActualEdit=sdf2Time.format(dActualEnd);
          	%>
          	<!-- 
          	<tr > 
          			<td width="120"><%=label.getLabelName("L_VisitActualStartTime")%></td>
          			<td  ><input type="text" name="sstarttime" value="<%=sActualStart%>"/>
          				<input type="hidden" name="starttime" value="<%=sActualStart%>"/>
          				</td>
          			<td width="120"><%=label.getLabelName("L_VisitActualEndTime")%></td>
          			<td ><input type="text" name="sendtime" value="<%=sActualEdit%>"/>
          				<input type="hidden" name="endtime" value="<%=sActualEdit%>"/>
          				</td>
          			
          	</tr>
          	
          	 -->
          	 <input type="hidden" name="starttime" value="<%=sActualStart%>"/>
          	 <input type="hidden" name="endtime" value="<%=sActualEdit%>"/>
          	<tr > 
          			<td width="10%"><%=label.getLabelName("L_BriefDescription")%></td>
          			<td  colspan="3"><custom:textarea name="feedbackinfo" property="description" cols="80"  rows="4"/></td>
          			
          	</tr>
          </table>
          
        </td>
      </tr>
      <%@ include file="/sfe/VisitPlanMain.inc"%>	
      <tr>
      	<td>
      		<table width="100%" cellspacing="0" cellpadding="0">
            <tr>
            	<td class="summary_top">
            	<input type="hidden" name="numrows" value="<%=num%>"/>
            	</td>
            </tr>
            <tr>
              <td class="td_center">
              	 <%
                java.text.SimpleDateFormat vsdf=new java.text.SimpleDateFormat(strFullDateFormat);
				String d1_temp = vsdf.format(firstweeknowcal.getTime());
				String d2_temp = vsdf.format(nowfirstcal.getTime());
			    if(d1_temp.equals(d2_temp)){
            	if (nCurUserId.equals(contactid)) {
              	%>
             			<a onclick="page_confirm();"><custom:button type="1" label="L_Confirm" imgsrc="new.gif" border="0" style="width:60"/></a>
             	  <%
            	}}%>
                <%if(oStatus!=null && oStatus.intValue()!=10){%>
           
                <%}%>
               <a onclick="parent.window.close();"><custom:button type="1" label="L_Close" imgsrc="new.gif" border="0" style="width:60"/></a>
              </td>
            </tr>
          </table>  
        </td>
      </tr>
    </table>
  </form>  
  <%@ include file ="/sfe/VisitPlanMainJs.inc" %>              	
</body>

</html>
	
